package com.fhj.utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.telephony.TelephonyManager;

public class DeviceInfo {

	
	/**
	 * 获取设备的编号
	 * @param context  上下文
	 * @return  设备的编号
	 */
	public  static String getDevicesId(Context  context ){
		if (context!=null) {
			TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
			return manager.getDeviceId();
			
		}
		return null;
	}
	/**
	 * 获取应用程序的版本号
	 * @param context 上下文
	 * @return 应用程序的版本号
	 */
	public  static int getVer(Context context) {
		if (context!=null) {
			PackageManager packageManager = context.getPackageManager();
			int ver= 0;
			PackageInfo info= null;
			try {
				info = packageManager.getPackageInfo(context.getPackageName(), 0);
			} catch (NameNotFoundException e) {
				e.printStackTrace();
			}
			ver=info.versionCode;
			return ver;
		}
		return 1;
	}
	
}
